{% extends "base.html" %}
{% block css %}
    <style>
        .btn-primary:hover {
            color: red;
        }
    </style>
{% endblock %}

{% block nav %}
    {% for object in model_list %}
        <li><a href="{{ object.url }}"><i class="{{ object.icon }}"></i>{{ object.model_name }}</a>
        </li>

    {% endfor %}

{% endblock %}

{% block crumbs %}
    <div class="row">
        <div class="col-md-12">
            <ol class="breadcrumb">
                <li class="active">
                    <a class="this-page" href="{% url 'base:project' %}">项目管理</a>
                </li>
                <li class="active">
                    <a class="this">添加项目</a>
                </li>
            </ol>

        </div>
    </div>
{% endblock %}

{% block body %}


    <div class="row">
        <div class="col-md-12">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">添加项目</h3>
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" method="post" action="{% url 'base:project_add' %}"
                          onsubmit="return check()">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">项目名称</label>
                            <div class="col-sm-6">
                                <input type="text" name="prj_name" id="prj_name" class="form-control">
                            </div>
                            {% if error %}
                                <span style="color: red; font-size: 10px;" id="error">{{ error }}</span>
                            {% endif %}
                            <span style="color: red; font-size: 10px;display: none" id="prj_error"></span>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">项目描述</label>
                            <div class="col-sm-6">
                                <textarea name="description" placeholder="请输入内容" class="form-control"
                                          rows="3"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">签名方式</label>
                            <div class="col-sm-6">
                                <select name="sign" class="form-control" required="required">
                                    {% for sign in sign_list %}
                                        <option value={{ sign.sign_id }}>{{ sign.sign_name }}</option>
                                    {% endfor %}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-6">
                                <button type="submit" class="btn btn-primary"><i
                                        class="fa fa-save"></i>&nbsp;保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>

            </div>

        </div>

    </div>

{% endblock %}
{% block javascript %}
    <script type="text/javascript">
        function check() {
            var prj_name = $("#prj_name").val();
            var error = $("#prj_error");
            if (prj_name.trim().length == 0) {
                error.html("项目名称不能为空哦！");
                error.show();
                return false
            } else {
                error.hide();
                return true
            }
        }
    </script>
{% endblock %}